﻿$(document).ready(function () {

    // Find all anchors with the class popup and add the onclick function to open the link in a new window.
    $('a.popup').click(function () {
        window.open($(this).attr('href'));
        return false;
    });

    // Traverse through all links with the class popup and modify the title attribute.
    $('a[class*="popup"]').each(function () {
        $(this).attr('title', $(this).attr('title') + ' (Opens in new window)');
    });

    // Find all divs with with answers and hide them
    $('div.answer').hide();

    $('#query').labelize();
    $('.google-translate').translate({ imageUrl: '/images/google-translate.png' });

    // Google Translate
    $('.translate').click(function () {
        if ($('#translate-dialog').length == 0)
            OpenTranslate(this)
        else
            $('#translate-dialog').remove();
        return false;
    });

    //Set focus to input field when displaying comment form
    $('#comment-form #name').focus();
});